package dev.mrchen.flows.core.util;

import java.io.Closeable;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;

public class IoUtil {

    public static void closeIo(Closeable closeable) {
        if ( null == closeable ){
            return;
        }
        try {
            closeable.close();
        } catch (IOException e) {
            //
        }
    }


    public static void copy(InputStream in , OutputStream out) throws IOException {
        byte[] bytes = new byte[8192];
        int len = 0;
        while ( (len = in.read(bytes)) != -1 ) {
            out.write(bytes , 0 , len);
        }
    }


}
